package com.hl233.framework.thread;

import com.hl233.framework.utils.RandomCode;

/**
 * @author 张振强15065206763
 * @create 2024-09-06
 */
public class BreadProducer implements Runnable{
    // 生产者名称
    private final String producerName;

    public BreadProducer(String producerName) {
        this.producerName = producerName;
    }

    @Override
    public void run() {
        while (true) {
            try {
                String bread = "测试"+ RandomCode.code(6);
                //每个人生产的面包都放到商店货柜上寄售
                BreadStore.put(bread);
                System.out.println(Thread.currentThread().getName() + "生产了面包，现在库存有：" + BreadStore.BREAD_STORE.size());
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
